﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EFBasic.Entities
{
    /*
    * Config Relationship: Convention < Annotation < FluentAPI
    * [Key], [Column(Order=1)], [Timestamp](only byte array)
    * [ConcurrencyCheck], [Required], [MaxLength], [StringLength], 
    * [Table("StudentMaster", Schema="Admin")]
    * [Column("Name")], [Column("Name", Order=1, TypeName="varchar")]
    * [ForeignKey("StandardRefId")]
    * [NotMapped] == a property which does not have either getters or setters
    */

    public class Student : BaseEntity
    {
        public Student()
        {

        }

        public int StudentId { get; set; } // Convention (Id or <classname>Id) -> primary key, indentity(type of numeric or GUID)
        public string StudentName { get; set; }
        public DateTime? DateOfBirth { get; set; }
        public byte[] Photo { get; set; }
        public decimal Height { get; set; }
        public float Weight { get; set; }

        /* Convention */
        // If not CF uses Standard_StandardId insteadof StandardId
        //Foreign key for Standard, has the name matches with primary key property
        public int? StandardId { get; set; }

        // Convention, navigation property
        public virtual Standard Standard { get; set; }

        // Map one-to-one
        public virtual StudentAddress StudentAddress { get; set; }

        public virtual ICollection<Course> Courses { get; set; }

        /* Annotation
        public int? StandardRefId { get; set; }
        [ForeignKey("StandardRefId")]
        public Standard Standard { get; set; }
        */
    }
    
    //public class Student : BaseEntity
    //{
    //    public Student()
    //    {

    //    }

    //    public int StudentID { get; set; } // Convention (Id or <classname>Id) -> primary key, indentity(type of numeric or GUID)
    //    public string StudentName { get; set; }
    //    public DateTime? DateOfBirth { get; set; }
    //    public byte[] Photo { get; set; }
    //    public decimal Height { get; set; }
    //    public float Weight { get; set; }

    //    public int? CurrentStandardId { get; set; }
    //    public int? PreviousStandardId { get; set; }

    //    [ForeignKey("CurrentStandardId")] // use with [InverseProperty("CurrentStandard")] on Standard class when have multiple relationships between the same classes
    //    public Standard CurrentStandard { get; set; }
    //    [ForeignKey("PreviousStandardId")]
    //    public Standard PreviousStandard { get; set; }
    //}
}
